//
// Created by liushuai on 2020/2/18.
//
#include "strStr.h"
<<<<<<< HEAD:cxx/algorithm/src/strStr.cc
#include "kmp.h"
int strStr(string a,string p){
    int result = -1;
    if(p.size()>a.size())
        return result;
    else if(p.size()==0 && a.size() >= 0)
        result = 0;
    else{
        for(int i=0;i<a.size();i++){
            if(a[i] != p[0])
                continue;
            else{
                if(a.substr(i,p.size()) == p){
                    result = i;
                    break;
                }

            }
        }
    }
    return result;
=======

#include "kmp.h"
int strStr(string a, string p) {
  int result = -1;
  if (p.size() > a.size())
    return result;
  else if (p.size() == 0 && a.size() >= 0)
    result = 0;
  else {
    for (int i = 0; i < a.size(); i++) {
      if (a[i] != p[0])
        continue;
      else {
        if (a.substr(i, p.size()) == p) {
          result = i;
          break;
        }
      }
    }
  }
  return result;
>>>>>>> dev:cxx/algorithm/common/src/strStr.cc
}
